<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>三个数排序</title>
  <style>
    body {
      font-family: Arial, sans-serif;
    }

    label {
      display: block;
      margin-bottom: 5px;
    }

    input {
      margin-bottom: 10px;
      padding: 8px;
    }

    button {
      padding: 8px 15px;
      background-color: #007BFF;
      color: white;
      border: none;
      cursor: pointer;
    }

    button:hover {
      background-color: #0056b3;
    }

    #result {
      margin-top: 15px;
      font-weight: bold;
    }
  </style>
</head>

<body>
  <label for="num1">请输入第一个数:</label>
  <input type="text" id="num1">
  <label for="num2">请输入第二个数:</label>
  <input type="text" id="num2">
  <label for="num3">请输入第三个数:</label>
  <input type="text" id="num3">
  <button onclick="sortNumbers()">排序</button>
  <div id="result"></div>

  <script>
    function sortNumbers() {
      const num1 = parseFloat(document.getElementById('num1').value);
      const num2 = parseFloat(document.getElementById('num2').value);
      const num3 = parseFloat(document.getElementById('num3').value);

      if (isNaN(num1) || isNaN(num2) || isNaN(num3)) {
        document.getElementById('result').innerHTML = "请输入有效的数字";
        return;
      }

      const numbers = [num1, num2, num3];
      numbers.sort((a, b) => a - b);

      document.getElementById('result').innerHTML = `排序后的结果是: ${numbers.join(', ')}`;
    }
  </script>
</body>

</html>